<?php include_once("../../common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once("controller/detail-list.php");                     // 当前页面的控制器 ?>
<?php include_once(ROOT_PATH_ . "/controller/common/module/head.php"); // 引入通用的头部 ?>

<? $system_part = $_REQUEST['now_extender']; ?>
<?
if(isset($_REQUEST['now_extender']))
{
    $system_part = $_REQUEST['now_extender'];
}

if(isset($_REQUEST['nowpageid']))
{
    $nowpageid = $_REQUEST['nowpageid'];
}

if(isset($_REQUEST['sortby']))
{
    $sortby = $_REQUEST['sortby'];
}

if(isset($_REQUEST['term_nid']))
{
    $term_nid = $_REQUEST['term_nid'];
}



?>


<?php include_once("controller/model/language.php");//属性名字 ?>
<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/script/site-function.php"); ?>
<?php include_once ("term-detail-function.php");?>


<?php 
update_exists('`'.$dbName.'`.`'.$table_Prefix."term`" , '`is_disabled`' , 2);//检查表是否有这个字段  如果没有自动生成
?>

<?php include_once("first_term.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<?php include_once(ROOT_PATH_ . "/controller/common/module/head.php"); // 引入通用的头部 ?>







<script type="text/jscript" src="asset/js/js.js" ></script>

	<?//js日期控件?>

<script src="/application/laydate/laydate.js"></script>



<?php include_once('modules/mod-nkeditor.php'); ?>







<!--kindeditor编辑器-->

<script type="text/jscript" src="asset/js/drop.js" ></script>

<script type="text/jscript" src="asset/js/drop_title.js" ></script>



    <style>

        .layui-input-block {

            margin-left: 130px;

        }



        .layui-form-label {



            width: 100px;

        }





    </style>

</head>



<body>



<div id="topbar">

<!--TopBar端點01-->

<?php include ROOT_PATH_ . '/controller/common/module/topbar.php'; ?>
<!--TopBar端點02-->

</div>



<div id="container">

<!--Container端點01-->

<div id="maincontent">

<!--maincontent端點01-->



<div id="sidebar">

<?php include ROOT_PATH_ . '/controller/common/module/sidebar.php'; ?>

</div>

<style>

			.info{

				width: 100%;

			}

		</style>

        







<div id="content">

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">

        <legend><h1>编辑<? echo $sys_title ?> 分类</h1></legend>

    </fieldset>





<div class="detail-box <? echo $system_part ?>">





        

<div class="term-detail-boxes layui-form">

<ul class="detail-boxing">

<form id="term_detail_form" method="post" onsubmit="return checkRequired(term_name);"  action="term-edit-function.php" enctype="multipart/form-data" name="uploadfile" class="  layui-form-pane">



            <input name="term_nid" type="hidden" value="<?php echo $term_nid?>" />

            <li class="mid"><label class="layui-form-label">人工编号：</label>

    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_mid" size="20" value="<?php echo $term_mid?>"></div>

                <em class="explain">(填写您自己设置的编号，人工编号不作排序)</em></li>

             

            <li class="name">

                <label class="layui-form-label">分类名称：</label>

    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_name" size="20" value="<?php echo $term_name?>"></div>

                <em class="explain">(<u style="color:red">*必填项目</u>,填写本分类的标题)</em>

            </li>

            


            <li class="term"><label class="layui-form-label">所属分类：</label>

            <?

			if($term_interm=='term1'){$now_term=$term_term1;}

			else{$now_term=$term_term2;} ?>

            

            <div class="layui-input-block">


                <select name="term_term_id" >
                    <option value="root"  <? if($term_interm=='root'){ echo "selected='selected'";} ?> >根目录</option>
                    <?php $term0=select_lines_all_items($table_prefix."term","","interm='root'"); ?>
                    <? for($i=0;$i<count($term0);$i++) { ?>
                        <option value="<?php echo $term0[$i]['nid'] ?>"  <? if($now_term==$term0[$i]['nid']){ echo "selected='selected'";} ?> > | - <?php echo $term0[$i]['name'] ?></option>
                        <?php $term1[$i]=select_lines_all_items($table_prefix."term","","term1 = {$term0[$i]['nid']} && interm = 'term1'"); ?>
                        <?for ($ii = 0; $ii < count($term1[$i]); $ii++) {?>
                            <option value="<?php echo $term1[$i][$ii]['nid'] ?>" <? if($now_term==$term1[$i][$ii]['nid']){ echo "selected='selected'";} ?> > |---- <?php echo $term1[$i][$ii]['name'] ?></option>
                            <?php $term2[$i][$ii]=select_lines_all_items($table_prefix."term","","term2 = {$term1[$i][$ii]['nid']} && interm = 'term2'"); ?>
                            <?for ($iii = 0; $iii < count($term2[$i][$ii]); $iii++) {?>
                                <option value="<?php echo $term2[$i][$ii][$iii]['nid'] ?>"> |------ <?php echo $term2[$i][$ii][$iii]['name'] ?></option>
                            <?php } ?>
                        <?php } ?>
                    <?php } ?>
                </select>




 </div>

                <em class="explain">本项不能修改</em>
            </li>

            

            




            <li class="listorder"><label class="layui-form-label">列表排序：</label>

    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_listorder" size="20" value="<? echo $term_listorder ?>" onkeydown="onlyNum();" onfocus="checkdefault(term_listorder)" onblur="checkempty(term_listorder)"></div>

                <em class="explain">(填写本分类在所属前台列表下的列表排序，数字越大，排序越靠前)</em></li>

        


			<li class="modifytime" style="display: none"><label class="layui-form-label">修改时间：</label>

    <div class="layui-input-block"><input type="text" class="layui-input"  name="term_modifytime" size="20" value="<? echo date("Y-m-d H:i:s") ?>" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" class="laydate-icon" ></div>

                <em class="explain">(填写分类修改时间)</em></li>

 

             <li class="publish"><label class="layui-form-label">发布状态：</label>

             

             	<div class="layui-input-block">

                    <input name='term_publish' type='radio' value='1'  title="立即发布" <?if($term_publish == '1'){echo "checked='checked'";}?>/>

                    <input name='term_publish' type='radio' value='0'  title="暂未发布" <?if($term_publish == '0'){echo "checked='checked'";}?>/>

                </div>

           

                <em class="explain">(选择立即发布，以上信息才能在前台显示；选择暂未发布，只对以上信息进行保存，不在前台显示)</em>

    

             </li>

			 



    

    <input name="term_interm" type="hidden" value="<? echo $term_interm ?>" />

             <input name="sys_part" type="hidden" value="<? echo $system_part ?>" />

             <input name="nowpageid" type="hidden" value="<? echo $_REQUEST['nowpageid'] ?>" />

             <input name="sortby" type="hidden" value="<? echo $_REQUEST['sortby'] ?>" />

             

             

        <div class="function">

            <input type="hidden" name="detail_attr" id="detail_attr" />

            <input type="hidden" name="goods_attr" id="goods_attr" />

            <input type="hidden" name="goods_attr2" id="goods_attr2" />

            <button class="layui-btn " lay-submit  type="button" lay-filter="formSub">立即提交</button>

            <input type="reset" class="layui-btn" value="重置"/>

        </div>

</form>

</ul>

</div>

</div>



<!--content端點01-->

</div>

<!--maincontent端點01-->

<br class="clearfloat" />

</div>

<!--container端點01-->

</div>





<?php include  ROOT_PATH_."/controller/modules/footer.php"; ?>





<script type="text/javascript">

layui.use(['transfer', 'layer', 'util', 'form'], function(){

	  var $ = layui.$

	  ,transfer = layui.transfer

	  ,layer = layui.layer

	  ,util = layui.util

	  ,form = layui.form;

	   

	

	var data1 = <?php echo $json_brand_list;?>  //显示搜索框

	transfer.render({

			elem: '#test4'

			,data: data1

			,title: ['全选', '全选']

			,showSearch: true

			,height:300

			,width:600

			,id: 'detail_attr_list'

			,value: [<?php echo $detail_relation_list;?>]

	})



    var data5 = <?php echo $json_goods_list;?>  //显示搜索框

            transfer.render({

                elem: '#test5'

                ,data: data5

                ,title: ['全选', '全选']

                ,showSearch: true

                ,height:300

                ,width:600

                ,id: 'goods_attr_list'

                ,value: [<?php echo $goods_relation_list;?>]

            })



    var data6 = <?php echo $json_goods_list;?>  //显示搜索框

        transfer.render({

            elem: '#test6'

            ,data: data6

            ,title: ['全选', '全选']

            ,showSearch: true

            ,height:300

            ,width:600

            ,id: 'goods_attr_list2'

            ,value: [<?php echo $goods_relation_list2;?>]

        })



<?php



    if( $detail_relation_list_json){?>

    var select_json = <?php echo $detail_relation_list_json;?>



            setRightPosition(select_json, '#test4');

    <?php }

    ?>



    <?php

    if( $goods_relation_list_json){?>

        var select_json5 = <?php echo $goods_relation_list_json;?>



                setRightPosition(select_json5, '#test5');

        <?php }?>



    <?php

    if( $goods_relation_list_json2){?>

    var select_json6 = <?php echo $goods_relation_list_json2;?>



        setRightPosition(select_json6, '#test6');

    <?php }?>





        form.on('submit(formSub)', function(data){

		 

		/*  var getData = transfer.getData('detail_attr_list'); 

		  

		  json_data = JSON.stringify(getData); */

		 

		  var ul = $("#test4").find("ul").eq(1);

			var input = $(ul).find("input");

			var saveArr = [];

			for(var i = 0; i < input.length; i++) {

				var inJson = {};

				

				inJson["title"] = input[i].title;

				inJson["value"] = input[i].value;

				saveArr.push(inJson);

			}



          json_data= JSON.stringify(saveArr)



          $('#detail_attr').val(json_data)



          // window.editor.sync();

          //

          //   window.editor2.sync();



          var ul5 = $("#test5").find("ul").eq(1);

          var input5 = $(ul5).find("input");

          var saveArr5 = [];

          for(var i = 0; i < input5.length; i++) {

              var inJson5 = {};



              inJson5["title"] = input5[i].title;

              inJson5["value"] = input5[i].value;

              saveArr5.push(inJson5);

          }



			json_data5= JSON.stringify(saveArr5)

		

		  $('#goods_attr').val(json_data5)





            var ul6 = $("#test6").find("ul").eq(1);

            var input6 = $(ul6).find("input");

            var saveArr6 = [];

            for(var i = 0; i < input6.length; i++) {

                var inJson6 = {};



                inJson6["title"] = input6[i].title;

                inJson6["value"] = input6[i].value;

                saveArr6.push(inJson6);

            }



            json_data6= JSON.stringify(saveArr6)



            $('#goods_attr2').val(json_data6)





			

			$('.layui-form-pane').submit() 	

	  })

	  

	  

});



//上移

		function moveUp(dom) {

			//找到选中的li

			var index = $("#"+dom+" ul" ).eq(1).find('.layui-form-checked').parent(); 

			if(typeof(index[0]) == "undefined") {

				layer.msg("请选中后，再进行移位操作");

				return;

			}

			for(var i=0;i<index.length;i++){

				if(index.eq(i).index()!=0){

					 index.eq(i).prev().before(index.eq(i));

				}

			}   

					

		}

		

		//置顶

		function moveUpMax(dom) {

			//找到选中的li

			var index = $("#"+dom+" ul" ).eq(1).find('.layui-form-checked').parent(); 

			if(typeof(index[0]) == "undefined") {

				layer.msg("请选中后，再进行移位操作");

				return;

			}

			for(var i=index.length-1;i>=0;i--){

				do{

					index.eq(i).prev().before(index.eq(i));

				}while(index.eq(i).index()!=0)

			}       			

		}

		

		//下移

		function moveDown(dom) {

			//找到选中的li

			var index = $("#"+dom+" ul" ).eq(1).find('.layui-form-checked').parent(); 

			if(typeof(index[0]) == "undefined") {

				layer.msg("请选中后，再进行移位操作");

				return;

			}

			for(var i=index.length-1;i>=0;i--){

				if(index.eq(i).index()!=($("#"+dom+" ul li").length-1)){

					 index.eq(i).next().after(index.eq(i));

				}

			}       			

		}

		

		//置底

		function moveDownMax(dom) {

			//找到选中的li

			var index = $("#"+dom+" ul" ).eq(1).find('.layui-form-checked').parent(); 

			if(typeof(index[0]) == "undefined") {

				layer.msg("请选中后，再进行移位操作");

				return;

			}

			for(var i=0;i<index.length;i++){

				do{

					index.eq(i).next().after(index.eq(i));

				}while(index.eq(i).index()!=($("#"+dom+" ul").eq(1).find("li").length-1))

			}       			

		}

		

		//穿梭框加载时不会按照设定的顺序来，需要删除重载

		function setRightPosition(json,dom) {

			var index = $(dom+ " ul").eq(1); 

			

			var list = json;

			var str = "";

			

			if(list){

				for(var i = 0; i < list.length; i++) {

					var inObj = list[i];

				

					var tagName = inObj.title;



					var htmlStr = $(index).children().children("input[title='"+tagName+"']").parent().prop("outerHTML");

				

					str += htmlStr;

				}

			}

			$(dom+" ul").eq(1).empty();

			$(dom+" ul").eq(1).append(str);

			

		}

		



</script>

</body>

</html>

